home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tclm_1_0.lha / tclm-1.0 / MLIB / mutil.h < prev   
C/C++ Source or Header  |  1993-08-16  |  4KB  |  108 lines

  1. /*-
  2.  * Copyright (c) 1993 Michael B. Durian.  All rights reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  * 1. Redistributions of source code must retain the above copyright
  8.  *    notice, this list of conditions and the following disclaimer.
  9.  * 2. Redistributions in binary form must reproduce the above copyright
  10.  *    notice, this list of conditions and the following disclaimer in the
  11.  *    documentation and/or other materials provided with the distribution.
  12.  * 3. All advertising materials mentioning features or use of this software
  13.  *    must display the following acknowledgement:
  14.  *    This product includes software developed by Michael B. Durian.
  15.  * 4. The name of the the Author may be used to endorse or promote 
  16.  *    products derived from this software without specific prior written 
  17.  *    permission.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  20.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  22.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  23.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29.  * SUCH DAMAGE.
  30.  */
  31. /*
  32.  * mutil.h,v 1.6 1993/05/06 21:44:06 durian Exp
  33.  */
  34. #ifndef MUTIL_H
  35. #define MUTIL_H
  36. #if defined(i386) || defined(vax)
  37. #    define mtohl(l) ((((l) << 24) & 0xff000000L) | (((l) << 8) & \
  38.         0x00ff0000L) | (((l) >> 8) & 0x0000ff00L) | (((l) >> 24) & \
  39.         0x000000ffL))
  40. #    define htoml(l) ((((l) << 24) & 0xff000000L) | (((l) << 8) & \
  41.         0x00ff0000L) | (((l) >> 8) & 0x0000ff00L) | (((l) >> 24) & \
  42.         0x000000ffL))
  43. #    define mtohs(s) ((((s) << 8) & 0xff00) | (((s) >> 8) & 0x00ff))
  44. #    define htoms(s) ((((s) << 8) & 0xff00) | (((s) >> 8) & 0x00ff))
  45. #else
  46. #    define mtohl(l) l
  47. #    define mtohs(s) s
  48. #    define htoml(l) l
  49. #    define htoms(s) s
  50. #endif
  51.  
  52. typedef enum {NORMAL = 0xff, SYSEX = 0xf0, METASEQNUM = 0x00, METATEXT = 0x01,
  53.     METACPY = 0x02, METASEQNAME = 0x03, METAINSTNAME = 0x04, METALYRIC = 0x05,
  54.     METAMARKER = 0x06, METACUE = 0x07, METACHANPREFIX = 0x20, METAEOT = 0x2f,
  55.     METATEMPO = 0x51, METASMPTE = 0x54, METATIME = 0x58, METAKEY = 0x59,
  56.     METASEQSPEC = 0x7f} EVENT_TYPE;
  57.  
  58. typedef struct {
  59.         char str[4];
  60.         long length;
  61.         short format;
  62.         short num_trks;
  63.         short division;
  64. } HCHUNK;
  65.  
  66. typedef struct {
  67.         char str[4];
  68.         long pos;
  69.         long length;
  70.     long msize;
  71.         unsigned char *events;
  72.         unsigned char *event_start;
  73.     unsigned char read_rs;
  74.     unsigned char write_rs;
  75. } TCHUNK;
  76.  
  77. /* hack to tell us when reading from stdin if there is anymore data */
  78. extern int MidiEof;
  79. extern char MidiError[];
  80.  
  81. /* function prototypes */
  82. #ifdef __STDC__
  83. #    define _ANSI_ARGS_(x) x
  84. #else
  85. #    define _ANSI_ARGS_(x) ()
  86. #endif
  87.  
  88. extern unsigned char get_running_state _ANSI_ARGS_((TCHUNK *));
  89. extern int get_smf_event _ANSI_ARGS_((TCHUNK *, unsigned char *, EVENT_TYPE *));
  90. extern int put_smf_event _ANSI_ARGS_((TCHUNK *, unsigned char *, int));
  91. extern int read_header_chunk _ANSI_ARGS_((int, HCHUNK *));
  92. extern int read_track_chunk _ANSI_ARGS_((int, TCHUNK *));
  93. extern int skip_track_chunk _ANSI_ARGS_((int));
  94. extern void rewind_track _ANSI_ARGS_((TCHUNK *));
  95. extern void reset_track _ANSI_ARGS_((TCHUNK *));
  96. extern int write_header_chunk _ANSI_ARGS_((int, HCHUNK *));
  97. extern int write_track_chunk _ANSI_ARGS_((int, TCHUNK *));
  98. extern int merge_tracks _ANSI_ARGS_((TCHUNK *, TCHUNK **, int *, int, int));
  99. extern int split_type_zero _ANSI_ARGS_((TCHUNK *));
  100. extern int fix2var _ANSI_ARGS_((long, unsigned char *));
  101. extern long var2fix _ANSI_ARGS_((unsigned char *, int *));
  102. extern void free_track _ANSI_ARGS_((TCHUNK *));
  103. extern void init_track _ANSI_ARGS_((TCHUNK *));
  104. extern int mread _ANSI_ARGS_((int, char *, int));
  105. extern int mwrite _ANSI_ARGS_((int, char *, int));
  106. extern int more_memory _ANSI_ARGS_((char **, int));
  107. #endif
  108.